class nvgpu::nouveau inherits nvgpu{
  case $operatingsystemmajrelease {
  '6': {
    file { '/etc/modprobe.d/nouveau.conf':
      ensure  => present,
      source  => 'puppet:///modules/nvgpu/nouveau.conf',
      before  => Exec['dracut'],
      owner   => 'root',
      group   => 'root',
    }

    exec { 'dracut':
      command     => "/sbin/dracut --force",
      timeout     => "1800",
    # notify      => Exec['force_reboot'],
      onlyif      => "/sbin/lsmod |grep nouveau"
    }
    #exec { 'force_reboot':
    #  command     => '/bin/echo b > /proc/sysrq-trigger',
    #  refreshonly => true,
    #}
    }
  '9': {
    file { '/etc/modprobe.d/nouveau.conf':
      ensure  => present,
      source  => 'puppet:///modules/nvgpu/nouveau.conf',
      owner   => 'root',
      group   => 'root',
    }->
    exec { 'dracut':
      command     => "/usr/bin/dracut --force",
      timeout     => "1800",
      notify      => Exec['force_reboot'],
      onlyif      => "/usr/sbin/lsmod |grep nouveau"
    }
    exec { 'force_reboot':
      #command     => '/usr/bin/echo b > /proc/sysrq-trigger',
      command     => '/usr/sbin/reboot',
      refreshonly => true,
    }
    }
  }


  file { [ "/usr/share/Mathematica/","/usr/share/Mathematica/Licensing" ]:
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    recurse    =>   true,
    ensure     =>   directory
  }

  file { "/usr/share/Mathematica/Licensing/mathpass":
    mode       =>  '0644',
    owner      =>  'root',
    group      =>  'root',
    source     =>  "puppet:///modules/${module_name}/mathpass",
    require    =>   File['/usr/share/Mathematica/Licensing']
  }



}
